package Gather.GatherExercise;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * ClassName:StudentText002
 * Package:Gather.GatherExercise
 * Description:
 *
 * @Author:ZhangXin
 * @Create2023/1/18-0:31
 * @Version:v1.0
 */
public class StudentText002 {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>();
        //2.键盘录入学生的信息,并添加到集合当中
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 3; i++){

            Student s= new Student();

            System.out.println("请输入学生的姓名");
            String name = sc.next();
            System.out.println("请输入学生的年龄");
            int age = sc.nextInt();

            //把name和age赋值给学生对象
            s.setName(name);
            s.setAge(age);

            //把学生对象赋值个集合
            list.add(s);
        }
        for (int i = 0; i < list.size(); i++) {
            Student stu = list.get(i);
            System.out.println(stu.getName()+","+stu.getAge());
        }

    }
}
